package com.t.bricks.bussiness.controller.msgagent;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.t.bricks.bussiness.model.msgagent.SendMsg;
import com.t.bricks.bussiness.service.msgagent.MsgAgentService;
import com.t.bricks.model.MsgEmity;

@RestController
@Api(value="消息代理", tags={"消息代理操作接口"})
@RequestMapping("/msg/")
public class MsgAgentController {

	/**
	 * 设备信息业务实现类
	 */
	@Autowired
	private MsgAgentService msgAgentService;

	/**
	 * 消息代理
	 * @param device 设备信息实体对象
	 * @return
	 */
	//[start]
	@ApiOperation(value="消息代理", response=SendMsg.class, notes="本接口用于接收信息然后发送到自开发的微信后台程序的信息接口,作用是简化程序间的互动代码")
	@ApiResponses({
		@ApiResponse(code=200, message="{\"success\": 布尔值, \"msg\": 文字提示, \"data\": 码值}"),
		@ApiResponse(code=400, message="错误的请求,请检查路径"),
		@ApiResponse(code=404, message="请求路径没有或页面跳转路径不对"),
		@ApiResponse(code=1000001, message="内部请求密钥错误"),
		@ApiResponse(code=1000002, message="您还没有登录或登录已超时,需要重新登录"),
		@ApiResponse(code=1000003, message="检查登录状态失败,请稍后重试！"),
		@ApiResponse(code=1000004, message="请求的操作不存在,请检查访问地址正确性，如大小写"),
		@ApiResponse(code=1000005, message="响应后在系统内部发生不可预知的错误"),
		@ApiResponse(code=1019000, message="1019000~1999999为拦截器调用方法错误"),
		@ApiResponse(code=8000, message="微信后台接收消息的url配置'app.wechat.push.msg.url'未进行配置"),
		@ApiResponse(code=8001, message="信息对象参数为空"),
		@ApiResponse(code=8002, message="接收人编号不能为空"),
		@ApiResponse(code=8003, message="接收人关注号不能为空"),
		@ApiResponse(code=8004, message="发送人不能为空"),
		@ApiResponse(code=8005, message="消息标题不能为空"),
		@ApiResponse(code=8006, message="消息内容不能为空"),
		@ApiResponse(code=8007, message="访问指定url地址失败,返回未定义的结果:NULL"),
		@ApiResponse(code=8008, message="访问指定url地址的结果值转换对象失败,转换结果为:NULL"),
		@ApiResponse(code=8009, message="8009~8998为新增时发生的其它错误")
	})
	//[end]
	@RequestMapping(method={RequestMethod.POST}, value="/agent")
	public MsgEmity add(@RequestBody SendMsg sendMsg) {
		return msgAgentService.agent(sendMsg);
	}
	
}
